package com.um.springboot.starter.configuration;

import com.um.springboot.starter.properties.HshProperties;
import io.minio.MinioClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 甘天伟
 * @since 2025/3/21
 * 版权所有 广州优匠科技有限公司
 */
@Configuration
@ConditionalOnProperty("hsh.sts.minio-enabled")
public class MinioConfiguration {

    @Autowired
    HshProperties hshProperties;

    @Bean
    public MinioClient minioClient() {
        return MinioClient.builder()
                .endpoint(hshProperties.getSts().getEndpoint())
                .credentials(hshProperties.getSts().getAccessKeyId(), hshProperties.getSts().getAccessKeySecret())
                .region(hshProperties.getSts().getRegion())
                .build();
    }
}
